import json
with open(r'C:\Users\SiliconValley520\Desktop\matrix.txt','rt',encoding='utf-8') as matrix_file:
    ls=json.loads(matrix_file.read())
    with open(r'C:\Users\SiliconValley520\Desktop\matrix.csv','at',encoding='utf-8') as matrix_csv_file:
        for line in ls:
            matrix_csv_file.write(line.replace(' ',','))
